package com.zhentao.controller;

import com.zhentao.model.article.dtos.ArticleDto;
import com.zhentao.model.article.dtos.ArticleHomeDto;
import com.zhentao.model.dtos.ResponseResult;
import com.zhentao.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/article/")
public class ApArticleController {

    @Autowired
    private ArticleService articleService;


    /**
     * 加载首页
     * @param articleHomeDto  加载首页参数
     * @return ResponseResult
     */
    @PostMapping("/load")
    public ResponseResult load(@RequestBody ArticleHomeDto dto){
        return articleService.load(0,dto);
    }

    /**
     * 加载最新
     * @param articleHomeDto  加载最新参数
     * @return ResponseResult
     */
    @PostMapping("/loadnew")
    public ResponseResult loadnew(@RequestBody ArticleHomeDto dto){
        return articleService.load(1,dto);
    }

    /**
     * 加载更多
     * @param articleHomeDto  加载首页参数
     * @return ResponseResult
     */
    @PostMapping("/loadmore")
    public ResponseResult loadmore(@RequestBody ArticleHomeDto dto){
        return articleService.load(2,dto);
    }


}
